<template>
	<div>
		<h2 class="text-info">版块管理</h2>
		<div>
			<table class="table ">
				<tr>
					<th>版块名称</th>
					<th>版块描述</th>
					<th>创建时间</th>
					<th>版主</th>
					<th>操作</th>
				</tr>
				<tr v-for="forum in forums" :key="forum.index">
					<td>{{forum.forumName}}</td>
					<td>{{forum.forumContent}}</td>
					<td>{{forum.forumTime | timef}}</td>
					<td>{{forum.username}}</td>
					<td><button @click="deleteForum(forum.id)" class="btn btn-danger">删除</button></td>
				</tr>

			</table>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				forums: {},
			}
		},
		created() {
			this.getAllForum();
		},
		methods: {
			getAllForum() {
				this.$http.get('/api/getAllForum').then(data => {
					if(data.status == 200) {
						this.forums = data.body;
					}
				}, err => {
					console.log(err);
				})
			},
			deleteForum(forumId) {
				var sure = confirm("确定删除？");
				//					if(sure == true){
				//						this.$http.get('/api/deleteForum',{params:{id:forumId}}).then(data=>{
				//							if(data.status == 200 ){
				//								this.getAllForum();
				//							}
				//						},err=>{
				//							console.log(err);
				//						})
				//					}

			}
		}

	}
</script>

<style>

</style>